﻿using SharpSoft.WPF.Adorners;
using SharpSoft.WPF.Masks;
using System;
using System.Collections.Generic;
using System.Text;
using System.Windows.Documents;
using System.Windows.Input;

namespace SharpSoft.WPF.Masks
{
    /// <summary>
    /// 用于操作Busy提示信息
    /// </summary>
    public class Mask : IMaskOperator
    {
        public Mask(VisualAdorner adorner, AdornerLayer adornerLayer)
        {
            this.Adorner = adorner;
            this.AdornerLayer = adornerLayer;
        }
        /// <summary>
        /// 装饰器对象
        /// </summary>
        public VisualAdorner Adorner { get; internal set; }

        /// <summary>
        /// 所属装饰器层 
        /// </summary>
        public AdornerLayer AdornerLayer { get; internal set; }

        /// <summary>
        /// 关闭遮罩层
        /// </summary>
        public void Close()
        {
            if (this.Adorner != null && this.AdornerLayer != null)
            {
                this.AdornerLayer.Remove(this.Adorner);
            }
        }
        /// <summary>
        /// 打开遮罩层
        /// </summary>
        public void Open()
        {
            if (this.Adorner != null && this.AdornerLayer != null)
            {
                this.AdornerLayer.Add(this.Adorner);
            }
        }


    }
    /// <summary>
    /// 不能创建装饰器的异常
    /// </summary>

    [Serializable]
    public class CanNotCreateAdornerException : Exception
    {
        public CanNotCreateAdornerException() { }
        public CanNotCreateAdornerException(string message) : base(message) { }
        public CanNotCreateAdornerException(string message, Exception inner) : base(message, inner) { }
        protected CanNotCreateAdornerException(
          System.Runtime.Serialization.SerializationInfo info,
          System.Runtime.Serialization.StreamingContext context) : base(info, context) { }
    }
}
